{
if (setjmp(gdx_jmp_buf)) {
char *vec_opts = NULL;
- gdx_info *gi = gdx_get_info();
+ const gdx_info *gi = gdx_get_info();
gpx_vec = find_vec("gpx", &vec_opts);
gpx_vec->rd_init(gi->from_device.canon);
} else {
const gdx_info *
gdx_read(const char *fname) {
- xml_init(fname, gdx_map, NULL);
- xml_read();
- xml_deinit();
+ // Test file open-able before gb_open gets a chance to fatal().
+ FILE *fin = fopen(fname, "r");
+
+ if (fin) {
+ fclose(fin);
+ xml_init(fname, gdx_map, NULL);
+ xml_read();
+ xml_deinit();
+ }
return my_gdx_info;
}
const gdx_info *gdx;
while (*dirlist) {
char *tbuf;
- xasprintf(&tbuf, "%s/%s", dirlist, "GarminDevice.xml");
- mountpoint = dirlist;
+ xasprintf(&tbuf, "%s/%s", *dirlist, "GarminDevice.xml");
+ mountpoint = *dirlist;
gdx = gdx_read(tbuf);
xfree(tbuf);
if (gdx) {
* Describes a file on the unit.
*/
typedef struct {
- const char *path;
- const char *basename;
- const char *extension;
- const char *canon; // full name, when applicable.
+ char *path;
+ char *basename;
+ char *extension;
+ char *canon; // full name, when applicable.
} gdx_file;
/*
* that is wants to read and write GPX files on a
* mounted drive. Try that now.
*/
- gdx = gdx_find_file(".");
+char *dlist[] = { ".", NULL};
+ gdx = gdx_find_file(dlist);
if (gdx) return 1;
/* Plan C. */
fatal("Found no Garmin USB devices.\n");